<?php

/**
 * Created by PhpStorm.
 * User: Se1per
 * Date: 2023/5/25
 * Time: 21:47
 */
spl_autoload_register(function ($className) {
    // 按照 PSR-4 命名空间规范转换类名和文件路径
    $filePath = str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';
 
    // 设置默认搜索目录为当前脚本所在目录
    $searchDirs = [__DIR__];

    foreach ($searchDirs as $dir) {
        $fullPath = "{$dir}/{$filePath}";

        if (file_exists($fullPath)) {
            require_once($fullPath);

            return;
        }
    }
    
    throw new RuntimeException("Class '{$className}' not found");
});

 
// 引入 composer 自动加载文件
require_once(__DIR__ . '/autoload.php');
